package admin

import (
	cachePkg "HeadLineNews/pkg/db/cache"
	"github.com/go-redis/redis/v8"
)

type Cache interface {
	RegAdminRegisterToken(adminId string) (token string, err error)
	RegAdminLoginToken(adminId string, groupIds ...string) (token string, err error)
}

type cache struct {
	cli *redis.Client
}

func NewCache() Cache {
	return &cache{cachePkg.AdminTokenCache()}
}

// RegAdminRegisterToken 管理员注册成功之后签发 token
func (c *cache) RegAdminRegisterToken(adminId string) (token string, err error) {
	return cachePkg.RegToken(c.cli, adminId)
}

// RegAdminLoginToken 管理员登录成功之后签发 token
func (c *cache) RegAdminLoginToken(adminId string, groupIds ...string) (token string, err error) {
	return cachePkg.RegToken(c.cli, adminId, groupIds...)
}
